package com.zzkk.database.data;


import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class DataSourceAop {
	@Before("execution(* com.zzkk.database.bh.mapper..*(..))")
	public void setDataSource2test01() {
		DynamicDataSourceHolder.putDataSource(DataSourceType.BH);
	}
	
	@Before("execution(* com.zzkk.database.admin.mapper..*(..))")
	public void setDataSource2test02() {
		DynamicDataSourceHolder.putDataSource(DataSourceType.ADMIN);
	}

	@After("execution(* com.zzkk.database.bh.mapper..*(..))")
	public void removeDataSourceBh(){
		DynamicDataSourceHolder.remove();
	}

	@After("execution(* com.zzkk.database.admin.mapper..*(..))")
	public void removeDataSourceAdmin(){
		DynamicDataSourceHolder.remove();
	}
}
